package com.whz.enumdemo;

/**
 * @Author: sinosoft
 * @Description: 薪资
 * 在五个工作日中 超过正常8个小时的工作时间都会产生加班工资
 * 在节假日中所有工作都产生加班工资
 * @Date: Create in 18:50 2021/5/13
 * @Modified By:
 */
public enum PayrollDay {
    MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;
    private static final int MINS_PER_SHIFT = 8 * 60;

    int pay(int minutesWorked, int payRate) {
        int basePay = minutesWorked * payRate;

        int overtimePay;
        switch (this) {
            case SUNDAY: case SATURDAY://周末
                overtimePay = basePay / 2;
                break;
            default: // 工作日
                overtimePay = minutesWorked <= MINS_PER_SHIFT ?
                        0 : (minutesWorked - MINS_PER_SHIFT) * payRate / 2;
        }
        return basePay + overtimePay;
    }
}
